import React, {FormEvent, FormEventHandler} from "react";

class Login extends React.Component<any, any> {
    userName = React.createRef<HTMLInputElement>()
    password = React.createRef<HTMLInputElement>()
    login = (event: FormEvent) => {
        event.preventDefault()
        alert(`用户名：${this.userName.current?.value}密码：${this.password.current?.value}`);
    }

    render() {
        return (
            <>
                <form onSubmit={this.login}>
                    用户名：<input ref={this.userName} type="text" placeholder="输入用户名"/>
                    密码：<input ref={this.password} type="password" placeholder="输入密码"/>
                    <button>登录</button>
                </form>
            </>
        );
    }
}

export default Login